<%@ page language="java" import="java.util.*, java.text.*,com.zjut.alipay.util.*,com.zjut.alipay.config.*, com.zjut.an.config.manager.*, 
com.zjut.an.config.dao.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,com.zjut.zs.util.tools.*,
com.zjut.zs.pay.dao.*, com.zjut.zs.pay.manager.*,com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,
java.io.*,net.sf.json.*" pageEncoding="utf-8"%>
<%
ZsPayManager pmanager = (ZsPayManager) SpringContextUtil.getBean("ZsPayManager");
DateUtil dateutil = (DateUtil) SpringContextUtil.getBean("DateUtil");
ZsUserStatusManager zsmanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");

String postdata = Common.getPostData(request.getInputStream(), request.getContentLength(), null);
System.out.println("支付后台反馈："+postdata); 

if (postdata != null) {
	JSONObject json = JSONObject.fromObject(postdata);
	if (json != null) {
		System.out.println(json.getString("orderAmt"));
		float orderAmt = Float.valueOf(json.getString("orderAmt"));
		if (orderAmt>0) {
			ZsPay pay = new ZsPay();
			pay.setOutTradeNo(json.getString("orderId"));
			
		    List list = pmanager.getDataByInstance(1,1,null,null,pay).getObjects();
			if (list.size()>0) {
				pay = (ZsPay)list.get(0);
				//pay.setTransactionId(trade_no);
				if (!Status.PAYSTATUS_YES.getStatus().equals(pay.getPayEnd())){
					pay.setTimeEnd(dateutil.getCurrentDate5());
					pay.setPayEnd(Status.PAYSTATUS_YES.getStatus());
					ZsUserStatus userstatus = zsmanager.getDataByUser(umanager.getData(pay.getUsId()));
					userstatus.setPayStatus(Status.PAYSTATUS_YES.getStatus());
					userstatus.setPayTime(dateutil.getCurrentDate5());
					zsmanager.updateData(userstatus);
					pmanager.updateData(pay);
					System.out.println("支付状态异步成功 ");
				} 
				response.getWriter().write("success");
			}				
		}
	} else {
		response.getWriter().write("fail");
	}
}
%>  